//运算符--的重载
#include <iostream>
using namespace std;
class Person{
    //声明函数operator<<s()是Person的友元类，可以访问Person的私有属性
    friend ostream& operator<<(ostream& cout,Person p);
public:
    Person(int x=0){
        this->x=x;
    }
    //前置--
    Person& operator--(){
        this->x--;
        return *this;    
    }
    //后置--的重载
    Person operator--(int){
        Person tmp=*this;
        this->x--;
        return tmp;
    }
private:
    int x;
};
//左移运算符的重载
ostream& operator<<(ostream& cout,Person p){
    cout<<p.x;
    return cout;
}
int main()
{
    Person p(3);
    cout<<p--<<endl;
    cout<<p<<endl;
    cout<<--p<<endl;
    cout<<p<<endl;
    return 0;
}